package main

import (
	"fmt"
	"github.com/golang-collections/collections/stack"
)

type stackQueue struct {
	stackIn *stack.Stack
	stackOut *stack.Stack
}

func newStackQueue() *stackQueue {
	sq := new(stackQueue)
	sq.stackIn = stack.New()
	sq.stackOut = stack.New()
	return sq
}

func (sq *stackQueue) push(e interface{}) {
	sq.stackIn.Push(e)

}

func (sq *stackQueue) pop() interface{} {

	if sq.stackOut.Len() == 0 {
		for sq.stackIn.Len() != 0 {
			sq.stackOut.Push(sq.stackIn.Pop())
		}
	}

	return sq.stackOut.Pop()
}

func main() {
	queue := newStackQueue()
	queue.push(1)
	queue.push(2)
	queue.push(3)
	queue.push(4)
	fmt.Println(queue.pop())
	fmt.Println(queue.pop())
	fmt.Println(queue.pop())
	fmt.Println(queue.pop())

}
